<template>
    <div class="phototinfo-container">
        <h4 class="title">{{photoinfo.title}}</h4>
        <p class="subtitle">
            <span>{{photoinfo.add_time |dateFormat('YYYY-MM-DD')}}</span>
            <span>点击: {{photoinfo.click}}次</span>
        </p>
        <hr>
        <!--缩略图区域-->
        <div class="preview">
            <vue-preview :slides="imglist" ></vue-preview>
        </div>

        <!--图片内容区域-->
        <div class="content" v-html="photoinfo.content"></div>
        <!--评论子组件-->
        <comment-box :id="id"></comment-box>
    </div>
</template>

<script>
    /*导入评论子组件*/
    import comment from '../comment.vue';
    import connector from '../../base/interface.js';

    export default {
        data(){
            return{
                /*路由中获取到图片id*/
                id:this.$route.params.id,
                /*图片详情*/
                photoinfo:{},
                imglist:[]
            }
        },methods:{
            getPohtoInfo(){
                /*获取图片详情*/
                connector.getPohtoInfo(this.id).then(result=>{
                    this.photoinfo=result;
                },err=>{
                    console.log(err.message);
                })
            },getImgList(){
                /*获取图片分享详情中的缩略图数组*/
                connector.getImgList(this.id).then(result=>{
                    result.forEach(item=>{
                        item.w=300;
                        item.h=300;
                        item.msrc = item.src;  //小图
                    });
                    this.imglist=result;
                },null)
            }
        },created(){
            this.getPohtoInfo();
            this.getImgList();
        },components:{
            "commentBox":comment
        }
    }
</script>

<style lang="scss" scoped>
.phototinfo-container{
    padding: 3px;
    .title{
        color: #26a2ff;
        font-size: 15px;
        text-align: center;
        margin: 15px 0;
    }
    .subtitle{
        display: flex;
        justify-content: space-between;
        font-size: 13px;
    }
    .content{
        font-size: 14px;
        line-height:25px;
    }
    .preview{
        img{
            width: 100px !important;
        }
    }
}
</style>